<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page language="java" import="java.util.*"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>媒体播放设置</title>
	<link rel="stylesheet" type="text/css" href="UI/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="UI/css/main.css"/>
    <script type="text/javascript" src="UI/js/libs/modernizr.min.js"></script>
    <link href="UI/users/bootstrap/css/bootstrap.min.css" rel="stylesheet">
   	<script src="UI/users/bootstrap/js/bootstrap.min.js"></script>
   	<script type="text/javascript" src="UI/jquery/jquery-2.1.0.js"></script>
<script type="text/javascript">

//定义一个全局变量，用来存储mediaId
var allMediaId="";

function addMediaToList(){

	/* 1：得到oneMedia的listvalue */
	/* 2. 构造一个<td>**</td>*/
	/* 3.将这个添加到    	toplaylistTable*/
	/* 4: 得到oneMedia的 listkey*/
	/* 5 . 将onemedia的listkey按顺序传到  form，传到后台*/
	
	var optionVal = $("#media").find("option:selected").text();
	
	console.log("optional : ",optionVal);
	
	var mediaFileName=$("<tr></tr>").text(optionVal);
	$('#toPlayListTable').append(mediaFileName);
	
	var mediaId=$("#media").val();
	console.log("mediaId : ",mediaId);
	allMediaId=allMediaId+mediaId+"@@";
	
	//将得到的mediaId传入到后台
	console.log("allMediaId: ",allMediaId);
}

function setAllMediaId(){
	
	$("#allMediaId").val(allMediaId);
	var sendToBackground=document.getElementById("allMediaId");
	
	console.log("sendToBackground: ",sendToBackground);
	
}

function validatePlayMedia(){
	var startHoursId=document.getElementById("startHoursId");
	var startMinutesId=document.getElementById("startMinutesId");
	var startSecondsId=document.getElementById("startSecondsId");
	var endHoursId=document.getElementById("endHoursId");
	var endMinutesId=document.getElementById("endMinutesId");
	var endSecondsId=document.getElementById("endSecondsId");
	if(startHoursId.value!="-1"){	
		if(startMinutesId.value!="-1"){	
			if(startSecondsId.value!="-1"){	
				if(endHoursId.value!="-1"){	
					if(endMinutesId.value!="-1"){	
						if(endSecondsId.value!="-1"){	
							return true;
						}else{
							alert("播放时间请设置正确");
							return false;
						}
					}else{
						alert("播放时间请设置正确");
						return false;
					}
				}else{
					alert("播放时间请设置正确");
					return false;
				}
			}else{
				alert("播放时间请设置正确");
				return false;
			}
		}else{
			alert("播放时间请设置正确");
			return false;
		}
		
	}else{
		alert("播放时间请设置正确");
		return false;
	}
	
}
</script>  
 	
</head>


<body>
<s:if test="null==#session.account">
	<s:a href="login.action" align="center"><h2>您不能直接访问网站内部页面,请先登录!</h2></s:a>
</s:if>
<s:else>
	    <s:if test="msg!=null">
	    	<script type="text/javascript">
	    		var message="${msg}";
	    		alert(message);
	    	</script>
	    </s:if>
        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i>
            <span class="crumb-name">首页</span><span class="crumb-step">&gt;</span>
            <span class="crumb-name">媒体管理</span><span class="crumb-step">&gt;</span>
            <span>播放媒体设置</span></div>
        </div>
 
              
       <div class="result-wrap">
            <div class="result-content">
					<form action="playMediaTogether" method="post" id="toPlayListForm" onsubmit="return validatePlayMedia()"  name="toPlayList" enctype="multipart/form-data">
	                    <s:textfield type="hidden" name="allMediaId" value="" id="allMediaId"></s:textfield>
	                   <!--  <input type="hidden" name="allMediaId" value="" id="allMediaId"/> -->
	                    <table class="insert-tab" width="100%">
	                        <tbody>
		                        <tr>
		                            <th width="120"><i class="require-red">*</i>此次名称：</th>
		                            <td>
		                                <s:textfield name="playlist.title" id="playlist.title" class="common-text required" type="text" size="50"></s:textfield>
		                            </td>
		                        </tr>
	                            <tr>
	                                <th><i class="require-red">*</i>开始时间：</th>
	                                <td>
	                                     <s:select headerKey="-1" headerValue="时" name="startHoursId" 
	                                     list="#{'0':'0','1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'9','10':'10',
	                                     '11':'11','12':'12','13':'13','14':'14','15':'15','16':'16','17':'17','18':'18',
	                                     '19':'19','20':'20','21':'21','22':'22','23':'23'}"/>
										<span>时</span><span>&nbsp;&nbsp;</span>
										
	                                	<s:select headerKey="-1" headerValue="分" name="startMinutesId" 
	                                	list="#{'0':'0','1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'9','10':'10',
	                                     '11':'11','12':'12','13':'13','14':'14','15':'15','16':'16','17':'17','18':'18',
	                                     '19':'19','20':'20','21':'21','22':'22','23':'23'}" />
	                                	<span>分</span><span>&nbsp;&nbsp;</span>
	                                
	                                	<s:select headerKey="-1" headerValue="秒" name="startSecondsId" 
	                                	list="#{'0':'0','1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'9','10':'10',
	                                     '11':'11','12':'12','13':'13','14':'14','15':'15','16':'16','17':'17','18':'18',
	                                     '19':'19','20':'20','21':'21','22':'22','23':'23'}"/>
	                                	<span>秒</span><span>&nbsp;&nbsp;</span> 
	                                </td>
	                            </tr>
	                            <tr>
	                                <th><i class="require-red">*</i>结束时间：</th>
	                                <td>
	                                     <s:select headerKey="-1" headerValue="时" name="endHoursId" 
	                                     list="#{'0':'0','1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'9','10':'10',
	                                     '11':'11','12':'12','13':'13','14':'14','15':'15','16':'16','17':'17','18':'18',
	                                     '19':'19','20':'20','21':'21','22':'22','23':'23'}"/>
	                                     <span>时</span><span>&nbsp;&nbsp;</span>
	                                	<s:select headerKey="-1" headerValue="分" name="endMinutesId" 
	                                	list="#{'0':'0','1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'9','10':'10',
	                                     '11':'11','12':'12','13':'13','14':'14','15':'15','16':'16','17':'17','18':'18',
	                                     '19':'19','20':'20','21':'21','22':'22','23':'23'}"/>
	                                	<span>分</span><span>&nbsp;&nbsp;</span>
	                                	<s:select headerKey="-1" headerValue="秒" name="endSecondsId" 
	                                	list="#{'0':'0','1':'1','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'9','10':'10',
	                                     '11':'11','12':'12','13':'13','14':'14','15':'15','16':'16','17':'17','18':'18',
	                                     '19':'19','20':'20','21':'21','22':'22','23':'23'}"/>
	                                	<span>秒</span><span>&nbsp;&nbsp;</span>
	                                </td>
	                            </tr>
	                            <tr>
		                            <th><i class="require-red">*</i>视频列表：</th>
		                            <td>
		                            	<s:select headerKey="-1" headerValue="--请选择--" id="media" name="media.id" list="mediaList" listKey="id" listValue="filename" required="required"/>
		                            	<span>&nbsp;&nbsp;&nbsp;</span>
		                            	<input type="button" class="btn btn-primary" id="adMedia" value="添加" onclick="addMediaToList()">
		                            </td>
	                            </tr>
	                            <tr>
		                            <th><i class="require-red">*</i>已加列表：</th>
		                            <td>
		                            	<div>
		                            		<table id="toPlayListTable" class="table-striped table-condensed">
												<thead>
													<tr>
														<th class="danger"><span>&nbsp;&nbsp;</span>视频名称<span>&nbsp;&nbsp;</span></th>
													</tr>
												</thead>
												<tbody>
								
												</tbody>
											</table>
		                            	</div>
		                            </td>
	                            </tr>	                            
	                            <tr>
	                                <th></th>
	                                <td>
	                                    <input class="btn btn-primary btn6 mr10" id="ok" value="确认" type="submit" onclick="setAllMediaId()">
	                                    <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
	                                </td>
	                            </tr>
	                        </tbody>
	                    </table>
               		</form>
            </div>
        </div>
</s:else>
</body>
</html>